﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
	public class StudentInfoConfig : IEntityTypeConfiguration<StudentInfo>
	{
		public void Configure(EntityTypeBuilder<StudentInfo> builder)
		{
			builder.ToTable("T_Student");
			builder.Property(s => s.UserName).HasMaxLength(20).IsRequired();
			builder.Property(s => s.Password).HasMaxLength(20).IsRequired();
			builder.Property(u => u.FullName).HasMaxLength(20).IsRequired();
			builder.Property(s => s.Phone).HasMaxLength(13).IsRequired();
			builder.Property(s => s.DelFlag).HasMaxLength(1).HasDefaultValue(0);
			builder.Property(s => s.Role).HasMaxLength(1).IsRequired();
			builder.Property(s => s.StuNum).HasMaxLength(20).IsRequired();
			builder.Property(s => s.AttendCount).HasDefaultValue(0);
			builder.Property(s => s.QuestionCount).HasDefaultValue(0);

			builder.HasIndex(g => g.StuNum).IsUnique();
			builder.HasIndex(g => g.UserName).IsUnique();




		}
	}
}
